package JavaBeans;

import java.sql.*;

public class DbUtil {
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	private ResultSet rs = null;
	public int updateSQL(String sql) {
		int n = -1;
		try {
			conn = DBConnection.getConnnection();
			pstmt = conn.prepareStatement(sql);
			n = pstmt.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		DBConnection.free(rs, pstmt, conn);
		return n;
	}
	public ResultSet QuerySQL(String sql) {
		try {
			conn = DBConnection.getConnnection();
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			return rs;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;

	}
}
